package ai;

import de.szut.pongsim.ai.User;
import de.szut.pongsim.physics.PadMovement;
import de.szut.pongsim.physics.Point;

public class DemoAI implements User {

	private Point ball;
	
	@Override
	public void setLeftSide() {
		// Simple AI, no orientation needed
	}

	@Override
	public void setRightSide() {
		// Simple AI, no orientation needed
	}

	@Override
	public PadMovement nextStep(int ownPadBottomY, int enemyPadBottomY) {
		return changePadMovement(ownPadBottomY + 2, ball.getY());
	}

	@Override
	public void updateBallPos(Point ballPos) {
		ball = ballPos;
	}

	private static PadMovement changePadMovement(int padY, int ballY) {
		if(padY > ballY) {
			return PadMovement.DOWN;
		} else if(padY < ballY) {
			return PadMovement.UP;
		} else {
			return PadMovement.STOP;
		}
	}
	
	@Override
	public void reset() {
		// Simple AI, no reset
	}

}
